/*************************************************************************
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, version 3 of the License.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 ************************************************************************/


/**
 * @file
 * Config.h
 *
 * @author
 * Pavel Hasenohrl (<a href="mailto:hasenpav@fel.cvut.cz">hasenpav@fel.cvut.cz</a>)
 *
 * @brief
 * This header contains class managing server configuration.
 */


#ifndef _CONFIG_H
#define _CONFIG_H

#include <string>

/**
 * @brief
 * Enumerate identifies config parameters.
 */
enum ConfigEntry {
  CE_CONFIGFILE,
  CE_LOWSIPPORT,
  CE_SIPPORTSIZE,
  CE_LOWRTPPORT,
  CE_RTPPORTSIZE,
  CE_CODEC,
  CE_RTMP_ADDR,
  CE_RTP_ADDR,
  CE_SIP_ADDR,
  CE_MAXENTRY
};

/**
 * @brief
 * Class providing access to config parameters and containing port range.
 */
class CConfig {
private:
  std::string m_strConfs[CE_MAXENTRY];

  static const char CONFIG_DELIMITER[];
  static const char *CONFIG_TABLE[CE_MAXENTRY];
  static const char *CONFIG_DEFAULT[CE_MAXENTRY];

  bool ParseFile();
public:
  CConfig();
  ~CConfig();

  /**
   * @brief Initialize config entries from config file.
   * @param[in] szFile path to config file
   * @return true when completes successfully
   */
  bool Init(const char *szFile);

  /**
   * @brief Retrieves config parameter.
   * @param[in] enum identifies config parameter to retrieve, mustn't be CE_MAXENTRY
   * @return const value of config parameter
   */
  const std::string &GetConfigEntry(ConfigEntry ce) const { return m_strConfs[ce]; }
};

#endif

